package com.axend.aerosense.common;

import android.content.Context;

import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.Utils;
import com.kingja.loadsir.core.LoadSir;
import com.axend.aerosense.base.app.BaseApplication;
import com.axend.aerosense.base.impl.IModuleInit;
import com.axend.aerosense.base.loadsir.EmptyCallback;
import com.axend.aerosense.base.loadsir.ErrorCallback;
import com.axend.aerosense.base.loadsir.LoadingCallback;
import com.axend.aerosense.base.loadsir.TimeoutCallback;
import com.axend.aerosense.base.utils.LogUtils;
import com.axend.aerosense.common.adapter.ScreenAutoAdapter;

/**
 * @author ChenHongWei
 * @date :2020/12/11 16:38
 */

public class CommonModuleInit implements IModuleInit {

    private static final boolean isDeBug = true;  //是否开启DeBug
    private static Context mContext;

    @Override
    public boolean onInitAhead(BaseApplication application) {
        mContext = application.getApplicationContext();
        if (isDeBug){
            ARouter.openLog();
            // 调试模式开启，如果在install run模式下运行，则必须开启调试模式
            ARouter.openDebug();
        }
        //阿里路由框架初始化
        ARouter.init(application);
        ScreenAutoAdapter.setup(application);
        LoadSir.beginBuilder()
                .addCallback(new ErrorCallback())
                .addCallback(new LoadingCallback())
                .addCallback(new EmptyCallback())
                .addCallback(new TimeoutCallback())
                .setDefaultCallback(LoadingCallback.class)
                .commit();
        Utils.init(application);
        LogUtils.d(this, "CommonModuleInit 初始化成功！");
        return false;
    }

    @Override
    public boolean onInitLow(BaseApplication application) {
        return false;
    }

    //初始化Tpns
    /*private void initTpns() {
        //开启debug模式
        XGPushConfig.enableDebug(this, true);
        XGPushManager.registerPush(this, new XGIOperateCallback() {
            @Override
            public void onSuccess(Object o, int i) {
                LogUtils.d(this, "TPNS注册成功！" + o);
            }

            @Override
            public void onFail(Object o, int i, String s) {
                LogUtils.d(this, "TPNS注册失败！错误码" + i + ",错误信息：" + s);
            }
        });
    }*/

    public static Context getmContext() {
        return mContext;
    }
}
